package org.tagging.exceptionHandler;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.tagging.exception.LoginWrongPlaceException;
import org.tagging.exception.UsernameAlreadyExistException;
import org.tagging.utils.ResponseUtils;
import org.tagging.utils.StatusCode;

@RestControllerAdvice
public class UserExceptionHandler {

    @ExceptionHandler({UsernameAlreadyExistException.class})
    public Object usernameAlreadyExistException(Exception e) {
        return ResponseUtils.build(StatusCode.USERNAME_ALREADY_EXIST, e.getMessage());
    }
    @ExceptionHandler({LoginWrongPlaceException.class})
    public Object loginWrongPlaceException(Exception e) {
        return ResponseUtils.build(StatusCode.LOGIN_WRONG_PLACE, e.getMessage());
    }

}
